package oop.ex1.filters;

import java.io.File;
/**
 * a filter thats filters files by comparing it's name
 * @author danalmog
 * @author danielshalev
 */
public class FileName extends NameDependent {
	
	/**
	 * a cunsrtucto that send the relevant arguments to it's super
	 * @param name the name to compare to
	 * @param hasNot determines if we should use as a NOT filter
	 */
	public FileName(String name,boolean hasNot) {
		super(name,hasNot);
	}
	
	/**
	 * compare the file name to the compare name and returns if they are equal
	 * @return true if the file name is equal to the desired name and false otherwise
	 */
	public boolean accept(File pathname){
		if((pathname.getName().toLowerCase().matches(getName().toLowerCase()) && !hasNot) ||
				(!pathname.getName().toLowerCase().matches(getName().toLowerCase()) && hasNot))
			return true;
		return false;
	}
}
